package com.example.androidnote.main;

import com.common.common.HttpRxObserver;
import com.example.androidnote.Injection;
import com.example.androidnote.domain.MainDomain;

public class MainPresenter extends MainContract.IMainPresenter {

    public MainPresenter(MainActivity view) {
        super(view);
    }

    @Override
    public void getChapter() {
        MainDomain mainDomain = Injection.mainDomain();
        mainDomain.execute()
                .subscribe(new HttpRxObserver<MainDomain.MainEntity>() {
                    @Override
                    protected void onHandleSuccess(MainDomain.MainEntity mainEntity) {
                        if (mainEntity.getErrorCode() == 0) {
                            mView.showMainPage(mainEntity);
                        }else {
                            mView.showToast(mainEntity.getErrorMsg());
                        }

                    }
                });
    }
}
